package com.outdoor.server.mapper;

import com.github.pagehelper.Page;
import com.outdoor.pojo.dto.UserPageQueryDTO;
import com.outdoor.pojo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    /**
     * 分页查询用户信息
     * @param userPageQueryDTO
     * @return
     */
    Page<User> page(UserPageQueryDTO userPageQueryDTO);

    /**
     * 根据id查询用户信息
     * @param id
     * @return
     */
    @Select("SELECT * FROM user WHERE id = #{id}")
    User getUserById(Long id);

    /**
     * 更新用户信息
     * @param user
     */
//    @Update("UPDATE user SET permission = #{permission}, type = #{type} WHERE id = #{id}")
    void updateUser(User user);

    @Select("SELECT * FROM user WHERE openid = #{openid}")
    User getByOpenid(String openid);

    void insert(User user);
}
